﻿//Created by Action Script Viewer - http://www.buraks.com/asv
package net.wooga.pets.controllers {
    import net.wooga.pets.events.*;
    import net.wooga.pets.models.vo.*;
    import net.wooga.pets.models.*;
    import net.wooga.pets.constants.*;
    import org.robotlegs.mvcs.*;
    import net.wooga.pets.models.world.*;

    public class CheckLettersCommandBAndC extends Command {

        public var tutorialModel:TutorialModel;
        public var worldModel:WorldModel;
        public var letterModel:LetterModel;
        public var userModel:UserModel;
        public var sessionModel:SessionModel;
        private var _waitingRoomID:String;

        override public function execute():void{
            if (((!(this.worldModel.building)) || (this.userModel.isVisitFriendsMode()))){
                return;
            };
            this._waitingRoomID = this.worldModel.getRoomIdsOfType(GameConstants.TYPE_WAITING_ROOM)[0];
            this.checkEnvelopes();
        }
        private function checkEnvelopes():void{
            if (this.userModel.level >= 4){
                this.addEnvelope(GameConstants.LETTER_KIOSK);
            };
            if (this.userModel.level >= 5){
                this.addEnvelope(GameConstants.LETTER_FONTAIN);
            };
            if (this.userModel.level >= 6){
                this.addEnvelope(GameConstants.LETTER_KINDERGARTEN);
            };
            if (this.userModel.level == 8){
                this.addEnvelope(GameConstants.LETTER_BUILD_TREATMENT_MENTAL);
            };
            if (this.userModel.level == 9){
                this.addEnvelope(GameConstants.LETTER_INVITE_FRIEND);
            };
            if (this.userModel.level == 14){
                this.addEnvelope(GameConstants.LETTER_BUILD_TREATMENT_PHYSICAL);
            };
            if (this.userModel.level == 18){
                this.addEnvelope(GameConstants.LETTER_BUILD_REHA_SPORT);
            };
            if (this.userModel.level == 22){
                this.addEnvelope(GameConstants.LETTER_BUILD_TREATMENT_COSMETICS);
            };
            if (this.userModel.level == 28){
                this.addEnvelope(GameConstants.LETTER_BUILD_REHA_FUN);
            };
        }
        private function addEnvelope(_arg1:String):void{
            var _local2:LetterVO = this.letterModel.getLetterById(_arg1);
            if (((_local2.isRead) || (((_local2.isBuildRoomLetter) && (this.worldModel.hasAreaType(_local2.roomTypeToBuild)))))){
                return;
            };
            dispatch(new InfoEvent(EventConstants.ADD_ENVELOPE, this._waitingRoomID, _local2));
        }

    }
}//package net.wooga.pets.controllers 
